<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableStudentChapterRelation extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {       
        $table  =  $this->table('student_chapter_relation',array('engine'=>'InnoDB'));
        $table->addColumn('student_id','integer',array('limit' => 30,'comment'=>'学生ID'))
            ->addColumn('chapter_id','integer',array('limit' => 30,'comment'=>'章节ID'))
            ->addColumn('is_lock','boolean',array('limit'=>4,'default'=>1,'comment'=>'0:己解锁,1:未解锁'))
            ->addColumn('is_complete','boolean',array('limit'=>4,'default'=>1,'comment'=>'0:己完成,1:未完成'))
            ->addColumn('create_time','datetime',array('comment'=>'创建时间'))
            ->addColumn('update_time','datetime',array('comment'=>'修改时间'))
            ->addColumn('delete_time','datetime',array('comment'=>'删除时间','null'=>true))
            ->create();
    }
}
